import request from '@/utils/request'
import { ApiModulesRoutes } from '@/consts.js'

/**
 * 分页查询人员列表
 * @param {String} data.keyword
 * @param {String} data.pageNo
 * @param {String} data.pageSize
 * @param {'INTERNAL_MEMBER','VISITOR'}  data.identityEnum
 */

export function findRecordsPersonPageByParam(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/record/person/findRecordsPersonPageByParam`,
    method: 'POST',
    data
  })
}

/**
 * 添加人员
 * @param {String} data.name
 * @param {String} data.orgId
 * @param {String} data.position
 * @param {Array} data.recordCarIds
 * @param {'INTERNAL_MEMBER','VISITOR'} data.identityEnum
 * @param {'GROUPLEADER',} data.superiorEnum
 * @param {String} data.remark
 * @param {String} data.userId
 */

export function addPersonRecord(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/record/person/addRecordsPerson`,
    method: 'POST',
    data
  })
}

/**
 * 修改人员
 * @param {String} data.name
 * @param {String} data.orgId
 * @param {String} data.position
 * @param {'INTERNAL_MEMBER','VISITOR'} data.identityEnum
 * @param {'GROUPLEADER','SUPERVISOR'} data.superiorEnum
 * @param {String} data.remark
 * @param {Array} data.recordCarIds
 * @param {String} data.userId
 * @param {String} data.id
 */

export function updateRecordsPerson(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/record/person/updateRecordsPerson`,
    method: 'POST',
    data
  })
}

/**
 * 查询车辆列表
 * @param {String} data.keyword
 * @param {String} data.pageNo
 * @param {String} data.pageSize
 * @param {'INTERNAL_MEMBER','VISITOR'}  data.identityEnum
 */

export function findRecordsCar(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/record/car/findRecordsCarPageByParam`,
    method: 'POST',
    data
  })
}

/**
 * 删除人员档案
 * @param {String} RecordProfileId       id
 */

export function apiDeleteProfile(RecordPersonId) {
  return request({
    url: `${ApiModulesRoutes.USER}/record/person/delRecordsPersonById`,
    method: 'GET',
    params: { RecordPersonId }
  })
}

/**
 * 批量删除人员档案
 * @param {Array} recordPersonIds       id
 */

export function delRecordsPersonBatch(recordPersonIds) {
  return request({
    url: `${ApiModulesRoutes.USER}/record/person/delRecordsPersonByIds`,
    method: 'POST',
    data: recordPersonIds
  })
}

/**
 * 查询所有组织
 */

export function findOrgList() {
  return request({
    url: `${ApiModulesRoutes.USER}/org/findOrgList`,
    method: 'POST',
    data: {}
  })
}

/**
 * 条件查询用户
 * @param {String} data.keyword
 * @param {String} data.pageNo
 * @param {String} data.pageSize
 */
export function findUserPageByParam(data) {
  return request({
    url: `${ApiModulesRoutes.USER}/user/findUserPageByParam`,
    method: 'POST',
    data
  })
}
